package com.igeek.oa.controller;

import cn.hutool.core.util.ObjectUtil;
import com.igeek.oa.entity.Employee;
import com.igeek.oa.entity.Officesupplies;
import com.igeek.oa.result.Result;
import com.igeek.oa.service.IEmployeeService;
import com.igeek.oa.service.IOfficesuppliesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/employee")
@Api("员工信息查询")
public class EmployeeConroller {
    @Autowired
    private IEmployeeService iEmployeeService;

    @ApiOperation("员工签到")
    @RequestMapping("/signIn/{eId}")
    public Result SignByRedis(@ApiParam("员工编号")@PathVariable("eId") String eId){
        return iEmployeeService.SignByRedis(eId);
    }

    @ApiOperation("获取所有员工信息")
    @GetMapping("/getemployees")
    public Result getEtemployees(){
        try {
            List<Employee> employeeList= iEmployeeService.getEmployees();
            if(ObjectUtil.isNotEmpty(employeeList)){
                return new Result(true,"查询所有员工信息成功",employeeList);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return new Result(true,"查询所有员工信息失败",null);
    }
}
